package dj.common.support;

import com.dj.common.exception.CentralException;
import com.dj.common.exception.CentralRunException;
import com.dj.common.exception.ErrorInfo;

/**
 * <br>
 * <p>
 * - ex handler
 * </p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/11/24 下午5:40
 */
public final class ExceptionHandler {

    private ExceptionHandler(){}

    public static CentralRunException buildRunEx(String msg) {
        return new CentralRunException(msg);
    }

    public static CentralRunException buildRunEx(Throwable throwable) {
        return new CentralRunException(throwable);
    }

    public static CentralRunException buildRunEx(String msg, Throwable throwable){
        return new CentralRunException(msg, throwable);
    }

    public static CentralRunException buildRunEx(ErrorInfo errorInfo) {
        return new CentralRunException(errorInfo.errorCode(), errorInfo.errorMsg());
    }

    public static CentralRunException buildRunEx(ErrorInfo errorInfo, Throwable throwable) {
        return new CentralRunException(errorInfo.errorCode(), errorInfo.errorMsg(), throwable);
    }

    public static CentralRunException buildRunEx(int code, String msg) {
        return new CentralRunException(code, msg);
    }

    public static CentralRunException buildRunEx(int code, String msg, Throwable throwable) {
        return new CentralRunException(code, msg, throwable);
    }

    public static CentralException buildEx(String msg) {
        return new CentralException(msg);
    }

    public static CentralException buildEx(Throwable throwable) {
        return new CentralException(throwable);
    }

    public static CentralException buildEx(String msg, Throwable throwable){
        return new CentralException(msg, throwable);
    }

    public static CentralException buildEx(ErrorInfo errorInfo) {
        return new CentralException(errorInfo.errorCode(), errorInfo.errorMsg());
    }

    public static CentralException buildEx(ErrorInfo errorInfo, Throwable throwable) {
        return new CentralException(errorInfo.errorCode(), errorInfo.errorMsg(), throwable);
    }

    public static CentralException buildEx(int code, String msg) {
        return new CentralException(code, msg);
    }

    public static CentralException buildEx(int code, String msg, Throwable throwable) {
        return new CentralException(code, msg, throwable);
    }



}
